
cc.Class({
    extends: cc.Component,

    properties: {
        _isAgree:true,
        account:cc.EditBox,
        password:cc.EditBox,
        _account:'',
        _password:''
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },
    wx_login(e,c){

    },
    nomal_login(e,c){
        game.http.request({
            url:'http://127.0.0.1:7001/login',
            method: 'POST',
            data:{
                account:this._account,
                password:this._password
            }
        },(err,data)=>{
            console.log(data);
        });
    },
    account_input(e,c){
        let account = this.account.string;
        this._account = account;
    },
    password_input(e,c){
        let password = this.password.string;
        this._password = password;
    },
    guest_register(e,c){
        if(this._account === '' || this._password == ''){
            game.openTip({
                content:'账号或者密码不能为空',
                ok_call:null,
                cancel_call:null
            });
            return;
        }
        let data = {
            account:this._account,
            password:this._password
        };
        game.guest_register(data);
    },
    guest_login(e,c){
        if(this._account === '' || this._password == ''){
            game.openTip({
                content:'账号或者密码不能为空',
                ok_call:null,
                cancel_call:null
            });
            return;
        }
        let data = {
            account:this._account,
            password:this._password
        };
        game.guest_login(data);
    },
    agree(toggle, customEventData){
        this._isAgree = toggle.isChecked;
        cc.log('this._isAgree',this._isAgree);
    }
});
